#include <iostream>
class Button {
public:
    virtual void render() = 0;
    virtual void onClick() = 0;
};

class WindowsButton: public Button
{
    WindowsButton() {}

    void render() override
    {
        std::cout<<"Windows render"<<std::endl;
    }
    void onClick() override
    {
        std::cout<<"Windows click"<<std::endl;
    }
};

class HTMLButton: public Button
{
    HTMLButton() {}

    void render() override
    {
        std::cout<<"HTML render"<<std::endl;
    }
    void onClick() override
    {
        std::cout<<"HTML click"<<std::endl;
    }
};

class Dialog{
private:
    Button *pBtn = nullptr;
public:
    void addButton()
    {
        pBtn = createButton();
    }
    void render()
    {
        pBtn->render();
    }
    virtual Button* createButton() = 0;
};

class WindowsDialog : public Dialog{
    Button* createButton() override
    {
        return new WindowsButton();
    }
};

class HTMLDialog : public Dialog{
    Button* createButton() override
    {
        return new HTMLButton();
    }
};
enum class DialogType{WindowsDialogType, HTMLDialogType};
int main() {
    DialogType select = DialogType::HTMLDialogType;
    Dialog *pD = nullptr;
    switch(select)
    {
        case DialogType::WindowsDialogType:
            pD = new WindowsDialog();
            break;
        case DialogType::HTMLDialogType:
            pD = new HTMLDialog();
            break;
    }
    pD->addButton();
    pD->render();
    return 0;
}
